<?php

    // 模块加载
    module('user');
    // 接收参数
    $props = api_var(array(
        'username','password','email','type','code',
    ) );
    // 实际功能
    class methods extends user {

        // 登录
        public function login($username, $password)
        {
            $token = $this->user_09241($username,$password);
            $token?export(true,'登录成功',array('token' => $token)):export(false,'登录失败');
        }
        // 发送邮件验证码
        public function send_mail($email)
        {
            $this->user_09243($email);
        }
        // 注册
        public function reg($username, $password, $email, $code)
        {
            $result = $this->user_09245($username,$password,$email,$code);
            if ($result) {
                // 成功那就登录
                $this->login($username,$password);
            } else {
                export(false,'注册失败');
            }
        }
        // 测试
        public function test()
        {
            // $this->user_09244('gudan666@126.com','495071');
            echo "test";
        }

    }

    $methods = new methods;

    switch ($props['type']) {
        case 'login':
            // 登录
            $methods->login($props['username'], $props['password']);
            break;
        case 'mail':
            $methods->send_mail($props['email']);
            break;
        case 'reg':
            $methods->reg($props['username'], $props['password'],$props['email'],$props['code']);
            break;
        case 'test':
            $methods->test();
            break;
        default:
            echo "<h1>:) hello world</h1>";
            break;
    }

?>